package com.cxhc.app.api.hcdoc;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cxhc.system.domain.hcdoc.HdYearFile;
import com.cxhc.system.service.hcdoc.IHdYearFileService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cxhc.common.annotation.Log;
import com.cxhc.common.core.controller.BaseController;
import com.cxhc.common.core.domain.AjaxResult;
import com.cxhc.common.enums.BusinessType;
import com.cxhc.common.utils.poi.ExcelUtil;
import com.cxhc.common.core.page.TableDataInfo;

/**
 * 年度资料Controller
 * 
 * @author Dhq
 * @date 2024-09-26
 */
@RestController
@RequestMapping("/api/hcDoc/yearFile")
public class HdYearFileController extends BaseController
{
    @Autowired
    private IHdYearFileService hdYearFileService;

    /**
     * 查询年度资料列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HdYearFile hdYearFile)
    {
        startPage();
        List<HdYearFile> list = hdYearFileService.selectHdYearFileList(hdYearFile);
        return getDataTable(list);
    }

    /**
     * 导出年度资料列表
     */
    @GetMapping("/export")
    public void export(HttpServletResponse response, HdYearFile hdYearFile)
    {
        List<HdYearFile> list = hdYearFileService.selectHdYearFileList(hdYearFile);
        ExcelUtil<HdYearFile> util = new ExcelUtil<HdYearFile>(HdYearFile.class);
        util.exportExcel(response, list, "年度资料数据");
    }

    /**
     * 获取年度资料详细信息
     */
    @GetMapping(value = "/detail/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hdYearFileService.selectHdYearFileById(id));
    }

    /**
     * 新增年度资料
     */
    @PostMapping("/insert")
    public AjaxResult add(@RequestBody HdYearFile hdYearFile)
    {
        return toAjax(hdYearFileService.insertHdYearFile(hdYearFile));
    }

    /**
     * 修改年度资料
     */
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody HdYearFile hdYearFile)
    {
        return toAjax(hdYearFileService.updateHdYearFile(hdYearFile));
    }

    /**
     * 删除年度资料
     */
    @GetMapping(value = "/delete/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(hdYearFileService.deleteHdYearFileById(id));
    }
}
